package com.mzj.saas.mservice.sys.controller;

import com.mzj.saas.commons.ResultBean;
import com.mzj.saas.mservice.sys.service.UserService;
import com.mzj.saas.mservice.sys.vo.AppUserVO;
import com.mzj.saas.mservice.sys.vo.ChangPassWordVo;
import com.mzj.saas.mservice.sys.vo.UserCodeRequestVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;


@Controller
@RequestMapping("/user")
@Api(tags = "用户信息管理")
public class UserController {
    private static final Logger LOG = LoggerFactory.getLogger(UserController.class);
    @Autowired
    private UserService userService;

    /*
     *app用户手机号密码注册
     */
    @PostMapping("phoneAndPasswordRegister")
    @ResponseBody
    public ResultBean<Object> phoneAndPasswordRegister(@RequestBody AppUserVO appUserVO) {
        return userService.phoneAndPasswordRegister(appUserVO);
    }

    /*
     *app-重置密码并登录
     */
    @ResponseBody
    @PostMapping("appForgetPassword")
    public ResultBean<Object> appForgetPassword(@RequestBody UserCodeRequestVO userCodeRequestVO) {
        return userService.appForgetPassword(userCodeRequestVO);
    }

    /*
     *pc忘记密码-验证验证码
     */
    @ResponseBody
    @PostMapping("checkPcForgetPassword")
    public ResultBean<Object> checkPcForgetPassword(@RequestBody UserCodeRequestVO userCodeRequestVO) {
        return userService.checkPcForgetPassword(userCodeRequestVO);
    }

    /*
     *pc-重置密码并登录
     */
    @ResponseBody
    @PostMapping("pcForgetPassword")
    public ResultBean<Object> pcForgetPassword(@RequestBody UserCodeRequestVO userCodeRequestVO) {
        return userService.pcForgetPassword(userCodeRequestVO);
    }


    /**
     * zyh
     * 2021.3.19
     * 修改密码
     */
    @ResponseBody
    @RequestMapping("changePassword")
    public ResultBean changePassword(@RequestBody ChangPassWordVo vo, @RequestHeader String accessToken) {
        return userService.changePassword(vo, accessToken);
    }

    /*
     *退出登录
     */
    @ResponseBody
    @RequestMapping("quitLogin")
    public ResultBean quitLogin(@RequestHeader String accessToken) {
        return userService.quitLogin(accessToken);
    }

    /**
     * xiaolong
     * 2023.3.16
     * 修改默认密码
     */
    @ResponseBody
    @PutMapping("/changeDefaultPassword")
    @ApiOperation("修改默认密码")
    public ResultBean changeDefaultPassword(@RequestBody ChangPassWordVo vo, @RequestHeader String accessToken) {
        return userService.changeDefaultPassword(vo, accessToken);
    }
}

